package com.ts.api.http.platform.biz;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gitee.apanlh.util.algorithm.encrypt.symmetric.AES;
import com.gitee.apanlh.util.base.*;
import com.gitee.apanlh.util.dataformat.JsonUtils;
import com.gitee.apanlh.util.valid.ValidParam;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.ts.api.http.platform.entity.apply.ApiPlatApplyBaJieJinFu;
import com.ts.api.http.platform.entity.dataexchange.ApiPlatDataExchangeBaJieJinFu;
import com.ts.api.module.api.convert.core.annotation.ApiPlan;
import com.ts.api.module.api.convert.core.annotation.ApiPlanConvertType;
import com.ts.api.module.api.convert.core.entity.ApiApplyParameter;
import com.ts.api.module.api.convert.core.entity.ApiBizStatus;
import com.ts.api.module.api.convert.core.entity.ApiDataExchangeParameter;
import com.ts.api.module.api.convert.platform.entity.RespPlatformMultiPhoneMaskDataExchange;
import com.ts.api.module.api.convert.platform.entity.RespPlatformNoticeApply;
import com.ts.api.module.api.convert.platform.entity.RespPlatformPhoneMaskApply;
import com.ts.api.module.api.convert.platform.entity.RespPlatformPhoneMaskDataExchange;
import com.ts.api.module.api.convert.platform.handler.ApiPlatformPhoneMaskConvertHandler;
import com.ts.api.module.api.entity.ApiProtocol;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * QD安心-八戒 掩码全流程37分 周结
 * @author 李源聪
 */
@ApiPlan(productId = "359", type = ApiPlanConvertType.PLAT_PHONE_MASK)
public class ApiPlatBaJieJinFuMaskConvert implements ApiPlatformPhoneMaskConvertHandler {

    private static final String KEY = "b81281e4813a174a";
    private static final String CHANNEL_SIGNATURE = "3Nga7YrpErXVBz53jgCffaW46IRlMsVSulgQLzcB0w";

    @Override
    public Object dataExchange(ApiDataExchangeParameter apiDataExchangeParameter) throws Exception {
        ApiPlatDataExchangeBaJieJinFu apiPlatDataExchangeBaJieJinFu = new ApiPlatDataExchangeBaJieJinFu();
        apiPlatDataExchangeBaJieJinFu.setPhone(apiDataExchangeParameter.getPhoneMask());

        apiPlatDataExchangeBaJieJinFu.setUserName("浩安星");

        apiPlatDataExchangeBaJieJinFu.setAge(apiDataExchangeParameter.getAge());

        apiPlatDataExchangeBaJieJinFu.setCity(apiDataExchangeParameter.getCity().replace("市", ""));

        // sex 1:男，0:女
        String sex = apiDataExchangeParameter.getSex();
        String sexChoose = ChooseEq.create()
                .when(sex, "0", "1")
                .when(sex, "1", "0")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSex(sexChoose);

        // education 0 小学 ， 1 初中 ，2 高中 ，3 中专 ，4 专科 ，5 本科 ，6 博士研究生
        // educationAttainment 学历
        // 1 初中及以下
        // 2 中专
        // 3 高中
        // 4 大专
        // 5 本科
        // 6 研究生及以上
        String educationAttainment = apiDataExchangeParameter.getEducationAttainment();
        String educationAttainmentValue = ChooseEq.create()
                .when(educationAttainment, "1", "1")
                .when(educationAttainment, "2", "2")
                .when(educationAttainment, "3", "3")
                .when(educationAttainment, "4", "4")
                .when(educationAttainment, "5", "5")
                .when(educationAttainment, "6", "6")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setEducationAttainment(educationAttainmentValue);

        // house 0 无房产 ，1 按揭房 ， 2 全款房不接受抵押 ， 3 全款房接受抵押；
        // realEstateInfo 房产情况
        // 1 无房产
        // 2 有房不抵押
        // 3 有房可抵押
        // 4 有房产
        // 5 有按揭房产
        // 6 有全款房产
        String realEstateInfo = apiDataExchangeParameter.getRealEstateInfo();
        String realEstateInfoValue = ChooseEq.create()
                .when(realEstateInfo, "1", "1")
                .when(realEstateInfo, "2", "3")
                .when(realEstateInfo, "3", "3")
                .when(realEstateInfo, "4", "3")
                .when(realEstateInfo, "5", "2")
                .when(realEstateInfo, "6", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setRealEstateInfo(realEstateInfoValue);

        // 1. 无车产 2. 有车产
        String carInfo = apiDataExchangeParameter.getCarInfo();
        String carInfoValue = ChooseEq.create()
                .when(carInfo, "1", "1")
                .when(carInfo, "2", "2")
                .when(carInfo, "3", "2")
                .when(carInfo, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCarInfo(carInfoValue);

        // creditCard 0 无信用卡 ，1 3千-5千 ，2 5千-1万 ，3 1万-2万 ，4 2万-3万 ，5 3万以上
        // creditLimit 信用卡额度
        // 1 无信用卡
        // 2 3千以下
        // 3 3千-1万
        // 4 1-3万
        // 5 3万以上
        // 6 有信用卡
        String creditLimit = apiDataExchangeParameter.getCreditLimit();
        String creditLimitValue = ChooseEq.create()
                .when(creditLimit, "1", "1")
                .when(creditLimit, "2", "2")
                .when(creditLimit, "3", "2")
                .when(creditLimit, "4", "2")
                .when(creditLimit, "5", "2")
                .when(creditLimit, "6", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCreditLimit(creditLimitValue);
        String loanPurpose = ChooseEq.create(apiDataExchangeParameter.getLoanPurpose())
                .when("1", "3")
                .when("2", "4")
                .when("3", "6")
                .when("4", "2")
                .when("5", "5")
                .when("6", "1")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setLoanPurpose(loanPurpose);

        // 1. 无保单 2. 缴纳不足一年 3.  缴纳1年以上 4 . 缴纳2年以上
        // insurancePolicy 保险保单
        // 1 无保险保单
        // 2 缴纳未满1年
        // 3 缴纳1年以上
        // 4 有保险保单
        String insurancePolicy = apiDataExchangeParameter.getInsurancePolicy();
        String insurancePolicyValue = ChooseEq.create()
                .when(insurancePolicy, "1", "1")
                .when(insurancePolicy, "2", "2")
                .when(insurancePolicy, "3", "3")
                .when(insurancePolicy, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setInsurancePolicy(insurancePolicyValue);

        // 1. 上班族 2. 公务员或事业单位 3. 私营业主（有营业执照）4. 个体户（无营业执照）5. 其他职业
        // career
        //   1	上班族
        //   2	自由职业
        //   3	企业主（有营业执照）
        //   4	公务员或事业单位
        //   5	个体户
        String career = apiDataExchangeParameter.getCareer();
        String careerValue = ChooseEq.create()
                .when(career, "1", "1")
                .when(career, "2", "5")
                .when(career, "3", "3")
                .when(career, "4", "2")
                .when(career, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCareer(careerValue);

        String monthlySalary = apiDataExchangeParameter.getMonthlySalary();
        String monthlySalaryValue = ChooseEq.create()
                .when(monthlySalary, "1", "1000")
                .when(monthlySalary, "2", "3000")
                .when(monthlySalary, "3", "8000")
                .when(monthlySalary, "4", "15000")
                .when(monthlySalary, "5", "30000")
                .end("1000");
        apiPlatDataExchangeBaJieJinFu.setMonthlySalary(monthlySalaryValue);

        // gongjijin 1. 无公积金 2. 缴纳未满6个月 3. 缴纳6个月以上
        String providentFund = apiDataExchangeParameter.getProvidentFund();
        String providentFundValue = ChooseEq.create()
                .when(providentFund, "1", "1")
                .when(providentFund, "2", "2")
                .when(providentFund, "3", "3")
                .when(providentFund, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setProvidentFund(providentFundValue);

        // 1. 无社保 2. 缴纳未满6个月 3. 缴纳6个月以上
        String socialSecurity = apiDataExchangeParameter.getSocialSecurity();
        String socialSecurityValue = ChooseEq.create()
                .when(socialSecurity, "1", "1")
                .when(socialSecurity, "2", "2")
                .when(socialSecurity, "3", "3")
                .when(socialSecurity, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSocialSecurity(socialSecurityValue);

        String sesameCredit = apiDataExchangeParameter.getSesameCredit();
        String sesameCreditValue = ChooseEq.create()
                .when(sesameCredit, "1", "600")
                .when(sesameCredit, "2", "649")
                .when(sesameCredit, "3", "699")
                .when(sesameCredit, "4", "700")
                .end("600");
        apiPlatDataExchangeBaJieJinFu.setSesameCredit(sesameCreditValue);

        String btLimit = apiDataExchangeParameter.getBtLimit();
        String btLimitValue = ChooseEq.create()
                .when(btLimit, "1", "1")
                .when(btLimit, "2", "2")
                .when(btLimit, "3", "3")
                .when(btLimit, "4", "4")
                .when(btLimit, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setBtLimit(btLimitValue);

        String salaryPayMethod = apiDataExchangeParameter.getSalaryPayMethod();
        String salaryPayMethodValue = ChooseEq.create()
                .when(salaryPayMethod, "1", "1")
                .when(salaryPayMethod, "2", "2")
                .when(salaryPayMethod, "3", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSalaryPayMethod(salaryPayMethodValue);
        String hbLimit = apiDataExchangeParameter.getHbLimit();
        String hbLimitValue = ChooseEq.create()
                .when(hbLimit, "1", "1")
                .when(hbLimit, "2", "2")
                .when(hbLimit, "3", "3")
                .when(hbLimit, "4", "4")
                .when(hbLimit, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setHbLimit(hbLimitValue);
        // 单位工龄 1:0-6个月，2:6~12个月，3:12个月以上
        String yearsService = ChooseEq.create(apiDataExchangeParameter.getYearsService())
                .when("1", "1")
                .when("2", "2")
                .when("3", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setYearsService(yearsService);
        apiPlatDataExchangeBaJieJinFu.setChannelSignature(CHANNEL_SIGNATURE);
        String iv = getIv();
        AES cbc = AES.createCbc(KEY.getBytes(), iv.getBytes());
        String encrypt = cbc.encryptToBase64Str(JsonUtils.toJson(apiPlatDataExchangeBaJieJinFu));
        Map<String, Object> map = MapUtils.newHashMap(newMap -> {
            newMap.put("data", encrypt);
            newMap.put("iv", iv);
            newMap.put("serialNo", apiDataExchangeParameter.getApplyId());
        });
        return JsonUtils.toJson(map);
    }

    @Override
    public RespPlatformMultiPhoneMaskDataExchange respDataExchange(String respJson) throws Exception {
        JSONObject jsonObject = JsonUtils.get(respJson);
        if (jsonObject == null) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }
        if (!Eq.object(jsonObject.getInteger("code"), 200)) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }
        JSONArray resData = jsonObject.getJSONArray("data");
        if (ValidParam.isEmpty(resData)) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }

        RespPlatformMultiPhoneMaskDataExchange respPlatformMultiPhoneMaskDataExchange = RespPlatformMultiPhoneMaskDataExchange.ofSuc();
        List<RespPlatformPhoneMaskDataExchange> listRespPlatformPhoneMaskDataExchange = CollUtils.newArrayList();

        for (int i = 0; i < resData.size(); i++) {
            JSONObject data = resData.getJSONObject(i);
            if (ValidParam.isNotNull(data)) {
                BigDecimal price = data.getBigDecimal("price");
                String companyName = data.getString("loanName");
                String productName = data.getString("productName");
                String serialNo = data.getString("serialNo");
                //  用户协议
                List<ApiProtocol> protocolList = CollUtils.newArrayList(newList -> {
                    //  获取协议
                    JSONArray listProtocolResult = data.getJSONArray("authorizationAgreement");
                    IteratorUtils.array(listProtocolResult, (item, index) -> {
                        JSONObject protocolObject = listProtocolResult.getJSONObject(index);
                        ApiProtocol protocol = new ApiProtocol();
                        protocol.setProtocolName(protocolObject.getString("name"));
                        protocol.setProtocolUrl(protocolObject.getString("url"));
                        newList.add(protocol);
                    });
                });

                //  获取手机号掩码
                List<String> listPhoneMd5 = CollUtils.newArrayList(newList -> {
                    JSONArray jsonArray = data.getJSONArray("hitPhoneList");
                    IteratorUtils.array(jsonArray, (protocolResult, index) -> {
                        String phoneMd5 = jsonArray.getString(index);
                        newList.add(phoneMd5);
                    });
                });
                RespPlatformPhoneMaskDataExchange result = RespPlatformPhoneMaskDataExchange.of();

                result.setPrice(price);
                result.setApplyId(serialNo);
                result.setDisplayName(companyName);
                result.setProductName(productName);
                result.setProtocolList(protocolList);
                result.setListPhoneMd5(listPhoneMd5);
                listRespPlatformPhoneMaskDataExchange.add(result);
            }
        }
        respPlatformMultiPhoneMaskDataExchange.setListPhoneMask(listRespPlatformPhoneMaskDataExchange);
        return respPlatformMultiPhoneMaskDataExchange;
    }

    @Override
    public Object apply(ApiApplyParameter apiApplyParameter) throws Exception {
        ApiPlatApplyBaJieJinFu apiPlatDataExchangeBaJieJinFu = new ApiPlatApplyBaJieJinFu();
        apiPlatDataExchangeBaJieJinFu.setPhone(apiApplyParameter.getPhone());

        apiPlatDataExchangeBaJieJinFu.setChannelSignature(CHANNEL_SIGNATURE);

        apiPlatDataExchangeBaJieJinFu.setUserName(apiApplyParameter.getUserName());

        apiPlatDataExchangeBaJieJinFu.setAge(apiApplyParameter.getAge());

        apiPlatDataExchangeBaJieJinFu.setCity(apiApplyParameter.getCity().replace("市", ""));

        // sex 1:男，0:女
        String sex = apiApplyParameter.getSex();
        String sexChoose = ChooseEq.create()
                .when(sex, "0", "1")
                .when(sex, "1", "0")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSex(sexChoose);

        // education 0 小学 ， 1 初中 ，2 高中 ，3 中专 ，4 专科 ，5 本科 ，6 博士研究生
        // educationAttainment 学历
        // 1 初中及以下
        // 2 中专
        // 3 高中
        // 4 大专
        // 5 本科
        // 6 研究生及以上
        String educationAttainment = apiApplyParameter.getEducationAttainment();
        String educationAttainmentValue = ChooseEq.create()
                .when(educationAttainment, "1", "1")
                .when(educationAttainment, "2", "2")
                .when(educationAttainment, "3", "3")
                .when(educationAttainment, "4", "4")
                .when(educationAttainment, "5", "5")
                .when(educationAttainment, "6", "6")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setEducationAttainment(educationAttainmentValue);

        // house 0 无房产 ，1 按揭房 ， 2 全款房不接受抵押 ， 3 全款房接受抵押；
        // realEstateInfo 房产情况
        // 1 无房产
        // 2 有房不抵押
        // 3 有房可抵押
        // 4 有房产
        // 5 有按揭房产
        // 6 有全款房产
        String realEstateInfo = apiApplyParameter.getRealEstateInfo();
        String realEstateInfoValue = ChooseEq.create()
                .when(realEstateInfo, "1", "1")
                .when(realEstateInfo, "2", "3")
                .when(realEstateInfo, "3", "3")
                .when(realEstateInfo, "4", "3")
                .when(realEstateInfo, "5", "2")
                .when(realEstateInfo, "6", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setRealEstateInfo(realEstateInfoValue);

        // 1. 无车产 2. 有车产
        String carInfo = apiApplyParameter.getCarInfo();
        String carInfoValue = ChooseEq.create()
                .when(carInfo, "1", "1")
                .when(carInfo, "2", "2")
                .when(carInfo, "3", "2")
                .when(carInfo, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCarInfo(carInfoValue);

        // creditCard 0 无信用卡 ，1 3千-5千 ，2 5千-1万 ，3 1万-2万 ，4 2万-3万 ，5 3万以上
        // creditLimit 信用卡额度
        // 1 无信用卡
        // 2 3千以下
        // 3 3千-1万
        // 4 1-3万
        // 5 3万以上
        // 6 有信用卡
        String creditLimit = apiApplyParameter.getCreditLimit();
        String creditLimitValue = ChooseEq.create()
                .when(creditLimit, "1", "1")
                .when(creditLimit, "2", "2")
                .when(creditLimit, "3", "2")
                .when(creditLimit, "4", "2")
                .when(creditLimit, "5", "2")
                .when(creditLimit, "6", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCreditLimit(creditLimitValue);
        String loanPurpose = ChooseEq.create(apiApplyParameter.getLoanPurpose())
                .when("1", "3")
                .when("2", "4")
                .when("3", "6")
                .when("4", "2")
                .when("5", "5")
                .when("6", "1")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setLoanPurpose(loanPurpose);

        // 1. 无保单 2. 缴纳不足一年 3.  缴纳1年以上 4 . 缴纳2年以上
        // insurancePolicy 保险保单
        // 1 无保险保单
        // 2 缴纳未满1年
        // 3 缴纳1年以上
        // 4 有保险保单
        String insurancePolicy = apiApplyParameter.getInsurancePolicy();
        String insurancePolicyValue = ChooseEq.create()
                .when(insurancePolicy, "1", "1")
                .when(insurancePolicy, "2", "2")
                .when(insurancePolicy, "3", "3")
                .when(insurancePolicy, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setInsurancePolicy(insurancePolicyValue);

        // 1. 上班族 2. 公务员或事业单位 3. 私营业主（有营业执照）4. 个体户（无营业执照）5. 其他职业
        // career
        //   1	上班族
        //   2	自由职业
        //   3	企业主（有营业执照）
        //   4	公务员或事业单位
        //   5	个体户
        String career = apiApplyParameter.getCareer();
        String careerValue = ChooseEq.create()
                .when(career, "1", "1")
                .when(career, "2", "5")
                .when(career, "3", "3")
                .when(career, "4", "2")
                .when(career, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setCareer(careerValue);

        String monthlySalary = apiApplyParameter.getMonthlySalary();
        String monthlySalaryValue = ChooseEq.create()
                .when(monthlySalary, "1", "1000")
                .when(monthlySalary, "2", "3000")
                .when(monthlySalary, "3", "8000")
                .when(monthlySalary, "4", "15000")
                .when(monthlySalary, "5", "30000")
                .end("1000");
        apiPlatDataExchangeBaJieJinFu.setMonthlySalary(monthlySalaryValue);

        // gongjijin 1. 无公积金 2. 缴纳未满6个月 3. 缴纳6个月以上
        String providentFund = apiApplyParameter.getProvidentFund();
        String providentFundValue = ChooseEq.create()
                .when(providentFund, "1", "1")
                .when(providentFund, "2", "2")
                .when(providentFund, "3", "3")
                .when(providentFund, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setProvidentFund(providentFundValue);

        // 1. 无社保 2. 缴纳未满6个月 3. 缴纳6个月以上
        String socialSecurity = apiApplyParameter.getSocialSecurity();
        String socialSecurityValue = ChooseEq.create()
                .when(socialSecurity, "1", "1")
                .when(socialSecurity, "2", "2")
                .when(socialSecurity, "3", "3")
                .when(socialSecurity, "4", "2")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSocialSecurity(socialSecurityValue);

        String sesameCredit = apiApplyParameter.getSesameCredit();
        String sesameCreditValue = ChooseEq.create()
                .when(sesameCredit, "1", "600")
                .when(sesameCredit, "2", "649")
                .when(sesameCredit, "3", "699")
                .when(sesameCredit, "4", "700")
                .end("600");
        apiPlatDataExchangeBaJieJinFu.setSesameCredit(sesameCreditValue);

        String btLimit = apiApplyParameter.getBtLimit();
        String btLimitValue = ChooseEq.create()
                .when(btLimit, "1", "1")
                .when(btLimit, "2", "2")
                .when(btLimit, "3", "3")
                .when(btLimit, "4", "4")
                .when(btLimit, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setBtLimit(btLimitValue);

        String salaryPayMethod = apiApplyParameter.getSalaryPayMethod();
        String salaryPayMethodValue = ChooseEq.create()
                .when(salaryPayMethod, "1", "1")
                .when(salaryPayMethod, "2", "2")
                .when(salaryPayMethod, "3", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setSalaryPayMethod(salaryPayMethodValue);
        String hbLimit = apiApplyParameter.getHbLimit();
        String hbLimitValue = ChooseEq.create()
                .when(hbLimit, "1", "1")
                .when(hbLimit, "2", "2")
                .when(hbLimit, "3", "3")
                .when(hbLimit, "4", "4")
                .when(hbLimit, "5", "4")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setHbLimit(hbLimitValue);
        // 单位工龄 1:0-6个月，2:6~12个月，3:12个月以上
        String yearsService = ChooseEq.create(apiApplyParameter.getYearsService())
                .when("1", "1")
                .when("2", "2")
                .when("3", "3")
                .end("1");
        apiPlatDataExchangeBaJieJinFu.setYearsService(yearsService);
        apiPlatDataExchangeBaJieJinFu.setChannelSignature(CHANNEL_SIGNATURE);
        String iv = getIv();
        AES cbc = AES.createCbc(KEY.getBytes(), iv.getBytes());
        String encrypt = cbc.encryptToBase64Str(JsonUtils.toJson(apiPlatDataExchangeBaJieJinFu));
        Map<String, Object> map = MapUtils.newHashMap(newMap -> {
            newMap.put("data", encrypt);
            newMap.put("iv", iv);
            newMap.put("serialNo", apiApplyParameter.getApplyId());
        });
        return JsonUtils.toJson(map);
    }

    @Override
    public RespPlatformPhoneMaskApply respApply(String respJson) throws Exception {
        JSONObject jsonObject = JsonUtils.get(respJson);
        if (jsonObject == null) {
            return RespPlatformPhoneMaskApply.ofFail();
        }
        if (!Eq.object(jsonObject.getInteger("code"), 200)) {
            return RespPlatformPhoneMaskApply.ofFail();
        }
        return RespPlatformPhoneMaskApply.ofSuc();
    }

    @Override
    public RespPlatformNoticeApply parseApplyNotice(RequestVO requestVO) {
        return null;
    }

    @Override
    public Map<String, Object> respApplyNotice(ApiBizStatus apiBizStatus) {
        return Map.of();
    }

    /***
     * 初始化向量（IV），它是一个随机生成的字节数组，用于增加加密和解密的安全性
     */
    private String getIv() {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 16; i++) {
            int number = random.nextInt(str.length());
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }
}
